var report_js = {};
$(document).ready(function(){
	common.body_to_all();
	vm.load();
	("#page_title").html("我的报告书");
});
var report = {};
report.list = [
	{
			//名称
			productsname:'测试名称',
			//条码号
			barcode:'8703737373337',
			//资源地址
			filepath:'https://noahealth.b0.upaiyun.com/messagePicture/2015/09/26/QQ%E6%88%AA%E5%9B%BE20150925231450.jpg',
			//展示时间
			enterdate:'2015-10-8',		
	},
	{
			//名称
			productsname:'测试名称2',
			//条码号
			barcode:'8703737373327',
			//资源地址
			filepath:'https://noahealth.b0.upaiyun.com/messagePicture/2015/10/07/QQ%E6%88%AA%E5%9B%BE20150929144935.png',
			//展示时间
			enterdate:'2015-10-9',	
	},	
];
var vm = avalon.define({
	$id:"mian_controller",
	//----------------
	//toast的信息
	toast_msg:'',
	//是否要展示toast
	is_toast_show:false,
	//定时器
	$timeout:0,
	//消息隐藏
	clear_toast:function(){
		//设置定时器
		if(vm.$timeout){
			clearTimeout(vm.$timeout);
		}
		vm.$timeout = setTimeout(function(){
			vm.is_toast_show = false;
			vm.toast_msg = '';
		},3000);		
	},	
	//-----------------	
	//直接跳转
	go_to_url:function(index){
		if(vm.list[index].barcode){
			location.href = vm.list[index].filepath;
		}else{
			vm.url = vm.list[index].filepath;
			$("#pic_modal").modal('show');
		}
	},
	//图片地址
	url:'',
	//关闭模态框
	close_modal:function(){
		$("#pic_modal").modal('hide');
	},
	//标记是否正在加载
	is_loading:false,
	list:[
		{
			//名称
			productsname:'',
			//条码号
			barcode:'',
			//资源地址
			filepath:'',
			//展示时间
			enterdate:'',
		}
	],
	//加载数据
	load:function(){
		vm.is_loading = true;
		$.ajax({
			type:"post",
			url:get_report_url,
			dataType:"json",
			success:function(data){
				console.log(data);
				vm.is_loading = false;
				vm.list = data;
			},	
			error:function(){
				vm.is_loading = false;
				vm.toast_msg = "网络错误";
				vm.is_toast_show = true;
				vm.clear_toast();					
			},			
		});		
	},
});
avalon.scan();
avalon.ready(function(){
	$('body').css('opacity',1);
});
